import request from '@/axios'
import { GradeParams, GradeResponse } from './types'

export const getTeacherApi = (params: GradeParams) => {
  return request.get<GradeResponse>({ url: '/teacher/list', params })
}

export const deleteTeacherByIdApi = (ids: string[] | number[]) => {
  return request.delete({ url: '/teacher/delete', data: { ids } })
}

export const saveTeacherApi = (data: any) => {
  return request[data.id ? 'put' : 'post']({
    url: data.id ? '/teacher/edit' : '/teacher/add',
    data
  })
}

export const getGradeApi = (params: GradeParams) => {
  return request.get<GradeResponse>({ url: '/teacher/grade', params })
}

export const deleteGradeByIdApi = (ids: string[] | number[]) => {
  return request.delete({ url: '/teacher/gradeDelete', data: { ids } })
}

export const saveGradeApi = (data: any) => {
  return request[data.id ? 'put' : 'post']({
    url: data.id ? '/teacher/gradeEdit' : '/teacher/gradeAdd',
    data
  })
}

export const getRealmApi = (params: GradeParams) => {
  return request.get<GradeResponse>({ url: '/teacher/realm', params })
}

export const deleteRealmByIdApi = (ids: string[] | number[]) => {
  return request.delete({ url: '/teacher/realmDelete', data: { ids } })
}

export const saveRealmApi = (data: any) => {
  return request[data.id ? 'put' : 'post']({
    url: data.id ? '/teacher/realmEdit' : '/teacher/realmAdd',
    data
  })
}
